package rabbitmq

import (
	amqp "github.com/rabbitmq/amqp091-go"
	"log"
	"time"
)

func publishMsg() {
	channel, _ := getChannel()

	body := "test-" + time.Now().Format("150405")
	msg := amqp.Publishing{
		ContentType: "text/plain",
		ContentEncoding: "",
		Body: []byte(body),
	}

	err := channel.Publish(exchange, routeKey, false, false, msg)
	if err != nil {
		log.Println(err.Error())
	}
	return
}

func pushDelay10() {
	channel, _ := getChannel()

	body := "test-1"
	msg := amqp.Publishing{
		ContentType: "text/plain",
		Body: []byte(body),
		Expiration: "10000",
	}

	err := channel.Publish(exchange, delayQueue1, false, false, msg)
	if err != nil {
		log.Println(err.Error())
	}
	return
}

func pushDelay30() {
	channel, _ := getChannel()

	body := "test-2"
	msg := amqp.Publishing{
		ContentType: "text/plain",
		Body: []byte(body),
		Expiration: "30000",
	}

	err := channel.Publish(exchange, delayQueue2, false, false, msg)
	if err != nil {
		log.Println(err.Error())
	}
	return
}
